<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListCommandeTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup styleClass="list" layout="block">
                <h:outputText escape="false" value="#{bundle.ListCommandeEmpty}" rendered="#{commandeController.items.rowCount == 0}"/> <br />
                <h:outputText value="Commandes en cours : #{commandeController.items.rowCount}" /> <br />
                <h:panelGroup rendered="#{commandeController.items.rowCount > 0}">
                    <h:commandLink action="#{commandeController.previous}" value="#{bundle.Previous} #{commandeController.pagination.pageSize}" rendered="#{commandeController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{commandeController.next}" value="#{bundle.Next} #{commandeController.pagination.pageSize}" rendered="#{commandeController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{commandeController.items}" var="item" border="0" cellpadding="2" cellspacing="0" 
                                 rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border: solid 1px;">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle}"/>
                            </f:facet>
                            <h:dataTable value="#{item.menuCollection}" var="itemMenu" border="0" style="border:none;" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" >
                                <h:column>   
                                    <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                        <h:outputText value="#{itemMenu.nom}"/>
                                    </h:panelGroup>
                                </h:column>
                            </h:dataTable>
                            <h:dataTable value="#{item.produitCollection}" var="itemProduit"  border="0" style="border:none;"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" >
                                <h:column>
                                    <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                        <h:outputText value="#{itemProduit.nom}"/>
                                    </h:panelGroup>
                                </h:column>
                            </h:dataTable>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_dateCommande}"/>
                            </f:facet>
                            <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                <h:outputText value="#{item.dateCommande}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_dateLivraison}"/>
                            </f:facet>
                            <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                <h:outputText value="#{item.dateLivraison}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                                </h:outputText>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_montant}"/>
                            </f:facet>
                            <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                <h:outputText value="#{item.montant} €"/>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_raisonRefus}"/>
                            </f:facet>
                            <h:outputText value="#{item.raisonRefus}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idStatut}"/>
                            </f:facet>
                            <h:panelGroup styleClass="statut_#{item.idStatut.idStatut}" layout="block">
                                <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                    <h:outputText value="#{item.idStatut.libelle}"/>
                                </h:panelGroup>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idClient}"/>
                            </f:facet>
                            <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                <h:outputText value="#{item.idClient.prenom} #{item.idClient.nom}"/>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idAdresse}"/>
                            </f:facet>
                            <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                <h:outputText value="#{item.idAdresse.adresse} \ #{item.idAdresse.codePostal} #{item.idAdresse.ville}"/>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idRestaurant}"/>
                            </f:facet>
                            <h:panelGroup styleClass="#{commandeController.commandeAlerte(item.dateLivraison)}" layout="block">
                                <h:outputText value="#{item.idRestaurant.nom}"/>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink styleClass="details" action="#{commandeController.prepareView}" value="#{bundle.ListCommandeViewLink}"/>
                            <br />
                            <h:commandLink styleClass="modifier" action="#{commandeController.prepareEdit}" value="#{bundle.ListCommandeEditLink}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
            </h:panelGroup>
            <br /> <br />
            <h:panelGroup styleClass="list" layout="block">
                <h:outputText escape="false" value="#{bundle.ListCommandeEmpty}" rendered="#{commandeController.itemsTermines.rowCount == 0}"/> <br />
                <h:outputText value="Commandes terminées : #{commandeController.itemsTermines.rowCount}" /> <br />
                <h:panelGroup rendered="#{commandeController.itemsTermines.rowCount > 0}">
                    <h:commandLink action="#{commandeController.previousItemsTermines}" value="#{bundle.Previous} #{commandeController.paginationItemsTermines.pageSize}" rendered="#{commandeController.paginationItemsTermines.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{commandeController.nextItemsTermines}" value="#{bundle.Next} #{commandeController.paginationItemsTermines.pageSize}" rendered="#{commandeController.paginationItemsTermines.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{commandeController.itemsTermines}" var="item" border="0" cellpadding="2" cellspacing="0" 
                                 rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border: solid 1px;">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitleTermines}"/>
                            </f:facet>
                            <h:dataTable value="#{item.menuCollection}" var="itemMenu" border="0" style="border:none;" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" >
                                <h:column>
                                    <h:outputText value="#{itemMenu.nom}"/>
                                </h:column>
                            </h:dataTable>
                            <h:dataTable value="#{item.produitCollection}" var="itemProduit"  border="0" style="border:none;"  rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" >
                                <h:column>
                                    <h:outputText value="#{itemProduit.nom}"/>
                                </h:column>
                            </h:dataTable>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_dateCommande}"/>
                            </f:facet>
                            <h:outputText value="#{item.dateCommande}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_dateLivraison}"/>
                            </f:facet>
                            <h:outputText value="#{item.dateLivraison}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_montant}"/>
                            </f:facet>
                            <h:outputText value="#{item.montant} €"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_raisonRefus}"/>
                            </f:facet>
                            <h:outputText value="#{item.raisonRefus}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idStatut}"/>
                            </f:facet>
                            <h:panelGroup styleClass="statut_#{item.idStatut.idStatut}" layout="block">
                                <h:outputText value="#{item.idStatut.libelle}"/>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idClient}"/>
                            </f:facet>
                            <h:outputText value="#{item.idClient.prenom} #{item.idClient.nom}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idAdresse}"/>
                            </f:facet>
                            <h:outputText value="#{item.idAdresse.adresse} \ #{item.idAdresse.codePostal} #{item.idAdresse.ville}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCommandeTitle_idRestaurant}"/>
                            </f:facet>
                            <h:outputText value="#{item.idRestaurant.nom}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink styleClass="details" action="#{commandeController.prepareViewItemsTermines}" value="#{bundle.ListCommandeViewLink}"/>
                            <br />
                            <h:commandLink styleClass="modifier" action="#{commandeController.prepareEditTermine}" value="#{bundle.ListCommandeEditLink}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
            </h:panelGroup>
            <h:commandButton id="bouton_refresh" action="#{commandeController.prepareList}" style="display: none;"/>
            <script language="javascript">
                
                function refresh(){
                    document.getElementById("main:bouton_refresh").click();
                }
                
                
                setTimeout("refresh()",15000);
            </script>
        </ui:define>
    </ui:composition>

</html>
